import http from '../util/http'
import wepy from 'wepy'
let urlMap = {
  prod: 'https://know-ledge.ministudy.com/study-api',
  test: 'https://know-ledge.ministudy.com/study-api',
  caoxin: 'https://know-ledge.ministudy.com/study-api',
  zhouyu: 'https://know-ledge.ministudy.com/study-api',
  haijian: 'https://know-ledge.ministudy.com/study-api',
  zhangyong: 'https://know-ledge.ministudy.com/study-api'
}
setTimeout(() => {
  let {prod, test} = wepy.$appConfig
  prod && Object.keys(urlMap).map((iv) => {
    urlMap[iv] = 'https://know-ledge.ministudy.com/study-api'
  })
  test && Object.keys(urlMap).map((iv) => {
    urlMap[iv] = 'http://172.18.70.102:5006/study-api'
  })
}, 0)
export default class base {
  static baseUrl = urlMap.prod
  static urlMap = urlMap
  static get = http.get.bind(http);
  static put = http.put.bind(http);
  static post = http.post.bind(http);
  static delete = http.delete.bind(http);
  static sleep = (time, cb) => {
    return new Promise((resolve) => setTimeout(() => {
      cb && cb()
      resolve()
    }, time))
  }
}
